using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Entity.Core.Objects;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Data.Entity.Core.Objects.DataClasses;
using System.Transactions;

namespace NeuroSpeech.WebAtoms.Mvc
{
    public class JsonValueProvider : IValueProvider
    {

        private Dictionary<string, object> _values;

        public JsonValueProvider(Dictionary<string, object> values)
        {
            _values = values;
        }

        public bool ContainsPrefix(string prefix)
        {
            return _values.ContainsKey(prefix);
        }

        public ValueProviderResult GetValue(string key)
        {
            ValueProviderResult result = null;
            object val = null;
            if (_values.TryGetValue(key, out val))
            {
                result = new ValueProviderResult(val, val != null ? val.ToString() : null, System.Globalization.CultureInfo.CurrentCulture);
            }
            return result;
        }
    }
}
